package com.basin.common.mongo.base;

import com.anwen.mongo.annotation.ID;
import com.anwen.mongo.annotation.collection.CollectionField;
import com.anwen.mongo.annotation.collection.CollectionLogic;
import com.anwen.mongo.enums.FieldFill;
import com.anwen.mongo.enums.IdTypeEnum;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serial;
import java.io.Serializable;
import java.util.Date;

/**
 * @author: Sam ZHONG | sammy1997@aliyun.com
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MongoBasicEntity implements Serializable {
    @Serial
    private static final long serialVersionUID = 1L;
    @ID(type = IdTypeEnum.AUTO)
    private String id;

    @CollectionField(fill = FieldFill.INSERT)
    private String createUser;
    @CollectionField(fill = FieldFill.INSERT)
    private Date createTime;
    @CollectionField(fill = FieldFill.INSERT_UPDATE)
    private String updateUser;
    @CollectionField(fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

    @CollectionLogic
    private String status;

    @CollectionField(exist = false)
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) // 入参能接 但返回时不序列化
//    @JsonProperty(access = JsonProperty.Access.READ_ONLY) // 反之
    private Integer current;
    @CollectionField(exist = false)
    @JsonProperty(access = JsonProperty.Access.WRITE_ONLY) // 入参能接 但返回时不序列化
    private Integer size;
}
